{% extends 'layout.html' %}
<!--
继承+重写
-->
{%block main%}
<div class="blog-container">
    <div class="">内容编辑页面</div>
    <div>当前用户：{{userinfo.username}}</div>
    <h3>文章:{{content.title}}（<span id="typeid">文章ID：{{content._id.toString()}}</span>）</h3>
    <div>当前分类：{{content.category.name}}</div>
        <form method="post">
            <div class="box">
                <label for="category">分类</label>
                <select name="category" id="category">
                    {%for item in category%}
                        {%if item._id.toString() === content.category._id.toString() %}
                            <option value="{{item._id.toString()}}" selected>{{item.name}}</option>
                        {%else%}
                            <option value="{{item._id.toString()}}">{{item.name}}</option>
                        {%endif%}
                    {%endfor%}
                </select>
            </div>
            <div class="box">
                <label for="title">标题</label>
                <input type="text" value="{{content.title}}" name="title" placeholder="title" id="title">
            </div>
            <div class="box">
                <label for="distribution">简介</label>
                <input type="text" value="{{content.distribution}}" name="distribution" placeholder="distribution" id="distribution">
            </div>
            <div class="box">
                <label for="content">内容</label>
                <textarea type="text" name="content" placeholder="content" id="content" cols="80" rows="10">{{content.content}}</textarea>
            </div>
            <button type="submit" id="tj">提交</button>
        </form>
</div>
<script>
    // bodyparser插件解析模式有问题，暂时只能用axios去提交请求
    // $(document).on('click','#tj',function () {
    //     const name = document.getElementById('name').value;
    //     const dd = {
    //         name: name,
    //         id:$('#typeid').html()
    //     };
    //     console.log(name);
    //     axios({
    //         method: 'post',
    //         url: '/admin/category/edit',
    //         data: dd
    //     }).then(function (response) {
    //         alert(response.data.name);
    //         window.location.href='http://localhost:8080/'+response.data.url;
    //     });
    // });

</script>
{%endblock%}
